home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c++ / 1038 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  1.8 KB

  1. Path: engnews1.Eng.Sun.COM!taumet!clamage
  2. From: boukanov@sentef1.fi.uib.no (Igor Boukanov)
  3. Newsgroups: comp.std.c++
  4. Subject: Re: sample auto_ptr template
  5. Date: 11 Apr 1996 16:47:47 GMT
  6. Organization: Fysisk institutt, Universitetet i Bergen
  7. Approved: clamage@eng.sun.com (comp.std.c++)
  8. Message-ID: <4kjcvb$ghf@ugress.uib.no>
  9. References: <009A0A5CE1159CC0.49802F14@ittpub.nl> <gregorDpoGM2.Hw2@netcom.com>
  10. NNTP-Posting-Host: taumet.eng.sun.com
  11. X-Nntp-Posting-Host: sentef1.fi.uib.no
  12. X-Newsreader: TIN [version 1.2 PL2]
  13. Content-Length: 886
  14. X-Lines: 23
  15. Originator: clamage@taumet
  16.  
  17. Greg Colvin (gregor@netcom.com) wrote:
  18. > This was a hard call, and I'm open to suggestions.  Adding a mutable
  19. > member to a class is never pretty, but making the member visible in any
  20. > way is ugly:  I don't like for a const argument to change its value,
  21. > and I think of the value of an object as being whatever its public
  22. > interface reveals. 
  23.  
  24. But why in this case instead of adding mutable member just change
  25. auto_ptr<T>(const auto_ptr<T>&) to auto_ptr<T>(auto_ptr<T>&)
  26. and 
  27. auto_ptr<T>& operator=(const auto_ptr<T>&) to
  28. auto_ptr<T>& operator=(auto_ptr<T>&)
  29.  
  30. This will explicitly reflect the semantic of auto_ptr and if somebody really 
  31. want to change the state of const object, they can explicitly wright
  32. about this:
  33. auto_ptr<someType> autoPtr(const_cast<auto_ptr<someType>&>(autoPtrConst)); 
  34.  
  35.  
  36. --
  37. Regards, Igor Boukanov. 
  38. igor.boukanov@fi.uib.no  
  39. http://www.fi.uib.no/~boukanov/
  40.  
  41.  
  42. [ comp.std.c++ is moderated.  To submit articles: try just posting with      ]
  43. [ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu         ]
  44. [ FAQ:      http://reality.sgi.com/employees/austern_mti/std-c++/faq.html    ]
  45. [ Policy:   http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
  46. [ Comments? mailto:std-c++-request@ncar.ucar.edu                             ]
  47.